package GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import java.awt.Color;
import javax.swing.JList;
import java.awt.Panel;
import java.awt.Button;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.ScrollPane;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import javax.swing.JPasswordField;
import javax.swing.JPopupMenu;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;
import javax.swing.JRadioButton;
import javax.swing.JCheckBox;
import java.awt.SystemColor;

public class SGi_Gui extends JFrame {

	private JPanel Login;
	private JTextField textField;
	private JPasswordField passwordField;
	public	String text;
	
	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					SGi_Gui frame = new SGi_Gui();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SGi_Gui() {
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		Login = new JPanel();
		Login.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(Login);
		Login.setLayout(new BorderLayout(0, 0));
		
		JPanel panel = new JPanel();
		panel.setForeground(Color.BLUE);
		panel.setBackground(SystemColor.activeCaptionBorder);
		Login.add(panel);
		
		textField = new JTextField();
		textField.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				String text=textField.getText();
				
				
			}
		});
		textField.addInputMethodListener(new InputMethodListener() {
			public void caretPositionChanged(InputMethodEvent arg0) {
			}
			public void inputMethodTextChanged(InputMethodEvent arg0) {
					
			}
		});
		textField.setToolTipText("Enter ID");
		textField.setBounds(84, 20, 120, 20);
		textField.setColumns(10);
		
		JLabel lblUserid = new JLabel("UserID");
		lblUserid.setForeground(Color.BLUE);
		lblUserid.setBackground(Color.BLUE);
		lblUserid.setBounds(10, 23, 64, 14);
		
		JLabel lblPassword = new JLabel("Password");
		lblPassword.setForeground(Color.BLUE);
		lblPassword.setBackground(Color.BLUE);
		lblPassword.setBounds(10, 61, 64, 14);
		panel.setLayout(null);
		
		JButton btnLogin = new JButton("Login");
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {            /*login button action */
				Worker_gui frame = new Worker_gui();
				frame.setVisible(true);
			}
			
		});
		btnLogin.setToolTipText("Confirm Login");
		btnLogin.setBounds(108, 92, 71, 23);
		panel.add(btnLogin);
		panel.add(lblUserid);
		panel.add(lblPassword);
		panel.add(textField);
		
		passwordField = new JPasswordField();
		passwordField.setToolTipText("Enter Password");
		passwordField.setBounds(84, 58, 120, 23);
		panel.add(passwordField);
		
		JButton btnCancel = new JButton("cancel");
		btnCancel.setBounds(211, 91, 76, 23);
		panel.add(btnCancel);
		
		JCheckBox chckbxRemmemberMe = new JCheckBox("remmember me");
		chckbxRemmemberMe.setBounds(239, 57, 120, 23);
		panel.add(chckbxRemmemberMe);
	}
	private static void addPopup(Component component, final JPopupMenu popup) {
		component.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			public void mouseReleased(MouseEvent e) {
				if (e.isPopupTrigger()) {
					showMenu(e);
				}
			}
			private void showMenu(MouseEvent e) {
				popup.show(e.getComponent(), e.getX(), e.getY());
			}
		});
	}
}
